let href = location.href;
function getUrlParams(url) {
       let reg = /^[^\s]+\?([^&\s\d]+=[^\s]+)*/
       let match = reg.exec(url)
       match = match[1]
       if (!match) {
           console.warn("没有匹配到相应的query参数")
           return null
       }
       let queryString = decodeURI(match);
       let queryArr = queryString.split("&");
       let queryParamsObj = {}
       queryArr.forEach(item => {
           let itemArr = item.split("=")
           queryParamsObj[itemArr[0]] = itemArr[1]
       })
       return queryParamsObj
   }
let qr = getUrlParams(href)
let { categoryid } = qr;
let { productListId} = qr;
let { title } =qr;
let { productName } = qr;
  let html = 
             `
             <li><a href="../index.html">首页></a></li>
             <li><a href="./bijia.html?title=${title}&categoryId=${categoryid}">${title}></a></li>
             <li><a href="#">${productName}</a></li>
             <li><a href="#">筛选</a></li>
            
             `
        $('ul').html(html);

 $.ajax({
            type: "get",
            url: `http://chst.vip:1234/api/getproduct?productid=${productListId}`
        }).then((res) => {
            var arr = res.result;
            let html = ''
            arr.forEach(item =>{
                 html += 
                 `
                 <div class="info">
                    <div class="pic">${item.productImg}</div>
                    <div class="title">${item.productName}</div>
                    <div class="count">
                         <div class="row">
                             <div class="co1">
                                <span>当前最低</span>
                                <span>¥6000</span>
                             </div>
                             <div class="co2">
                               <span>优选评论</span>
                               <span>8266条</span>
                             </div>
                          </div>
                     </div>
                  </div>
                 <div class="price">${item.bjShop}</div>

                 `
        })
        $('.content').html(html)

        $.ajax({
            type: "get",
            url: `http://chst.vip:1234/api/getproductcom?productid=${productListId}`
        }).then((res) => {
            var arr = res.result;
            let html = ''
            arr.forEach(item =>{
                 html += 
                 `
                 <div class="comment1">
                 <div class="top">
                     <span class="id">${item.comName}</span>
                     <span class="time">${item.comTime}</span>
                 </div>
                 <div class="middle">${item.comContent}</div>
                 <div class="bottom">
                     <span>${item.comFrom}</span>
                 </div>
             </div>
                 `
            })
            $('.commentRead').html(html)
        })
})